var vm = new Vue({
    el: '#list',
    data () {
        
        return {
          host,
          username:'',
          goods_sku_list:[],
        }
      },
    mounted(){
        let user = localStorage.username;    
        
        this.username = user;
        
        this.get_categorie_id();
        // this.username = user;
        this.show_goods();
        // this.fnGetgoods();
      },
    methods:{
        fnQuit:function(){
           sessionStorage.clear();
           localStorage.clear();
        //    this.$router.push({path:'/'});
           location.href = 'index.html';

        },
        
        show_goods:function(){
            // this.id = this.$route.query.sku_id;
                var url = this.host + '/goods/show/' + this.categorie_id + '/'
                axios.get(url, {
                      responseType: 'json',
                  })
                    .then(response => {
                          this.goods_sku_list = response.data;
                      
                      })
                      .catch(error => {
                          console.log(error.response);
                      })
             },
             // 从路径中提取sku_id  single-product.html?sku_id=1
        get_categorie_id: function(){
        // console.log("document.location.pathname="+document.location.toString())
            var re = /\/Product_List.html\?categorie_id=(\d)$/;
            this.categorie_id = document.location.toString().match(re)[1];
        },

        goods_detail:function(id){
          location.href = 'Product_Detailed.html?sku_id='+id;
          // this.$router.push({path:'/single-product.html',query:{sku_id:id}});

        },
    }
});